export default {
	namespaced: true,
	state: {
		fileLists: [], //文件列表
		directoryList: [{
			//深度list
			id:'//:',
			name: '根目录'
		}], //当前目录列表
	},
	getters: {
		/**
		 * isALL  : 是否全局
		 * condition :  条件
		 */
		getFileData: (state) => (isALL, condition) => {
			let dataList = [];
			if (isALL) {
				dataList = state.fileLists;
			} else {
				// 当前目录
				const id = state.directoryList[state.directoryList.length - 1].id;
				state.fileLists.forEach(item => {
					if (item.father_id == id) {
						dataList.push(item);
					}
				});
			}
			if (condition) {
				let temp = [];
				dataList.forEach(item => {
					if (item.file.name.indexOf(condition) >= 0) {
						temp.push(item);
					}
				});
				dataList = [...temp];
			}
			return dataList;
		}
	},
	mutations: {
		setFileList: (state, data) => {
			state.fileLists = data;
		},
		setDirectory: (state, data) => {
			state.directoryList = data;
		}
	},
	actions: {}
}
